

import { filterRepeat } from '@/sever/utils.js';
export const initOBD = {
  data() {
    return {
      // 双轮张力机设备参数
      doubleMachParams: [
        {
          name: '1轮预置张力',
          code: 'tension1_set',
          unit: "kN",
          value: '—'
        },
        {
          name: '1轮张力',
          code: 'tension1',
          unit: "kN",
          value: '—'
        }, {
          name: '2轮预置张力',
          code: 'tension2_set',
          unit: "kN",
          value: '—'
        }, {
          name: '2轮张力',
          code: 'tension2',
          unit: "kN",
          value: '—'
        }, {
          name: '牵引力',
          code: 'force1',
          unit: "kN",
          value: '—'
        }, {
          name: '预置牵引力',
          code: 'force_set1',
          unit: "kN",
          value: '—'
        }, {
          name: '1轮速度',
          code: 'speed1',
          unit: "km/h",
          value: '—'
        },  {
          name: '2轮速度',
          code: 'speed2',
          unit: "km/h",
          value: '—'
        }, {
          name: '1轮放线里程',
          code: 'length1',
          unit: "m",
          value: '—'
        },{
          name: '2轮放线里程',
          code: 'length2',
          unit: "m",
          value: '—'
        }, {
          name: '放线总里程1',
          code: 'total_length1',
          unit: "m",
          value: '—'
        },{
          name: '放线总里程2',
          code: 'total_length2',
          unit: "m",
          value: '—'
        },{
          name: '控制手柄位置',
          code: 'joyst',
          unit: "%",
          value: '—'
        }, {
          name: '油门踏板位置',
          code: 'pedal',
          unit: "%",
          value: '—'
        }, {
          name: '1轮制动',
          code: 'Brake1',
          value: '—'

        }, {
          name: '2轮制动',
          code: 'Brake2',
          value: '—'
        }, {
          name: '1轮工况',
          code: 'Work_select1',
          value: '—'
        }, {
          name: '2轮工况',
          code: 'Work_select2',
          value: '—'
        },
        {
          name: '控制模式',
          code: 'Control_mode',
          value: '—'
        },
        {
          name: '并轮状态',
          code: 'bParallel_status',
          value: '—'
        }, {
          name: '风扇开关',
          code: 'Fan_IN',
          value: '—'
        }, {
          name: '风扇状态',
          code: 'Fan_WORK',
          value: '—'
        }, {
          name: '计程状态1',
          code: 'count_set1',
          value: '—'
        }, {
          name: '计程状态2',
          code: 'count_set2',
          value: '—'
        },

      ],
      // 单轮张力机设备参数
      singleMachParams: [
        {
          name: '预置张力',
          code: 'tension1_set',
          unit: "kN",
          value: '—'
        },
        {
          name: '实际张力',
          code: 'tension1',
          unit: "kN",
          value: '—'
        },
        {
          name: '牵引力',
          code: 'force1',
          unit: "kN",
          value: '—'
        },
        {
          name: '预置牵引力',
          code: 'force_set1',
          unit: "kN",
          value: '—'
        },
        {
          name: '1轮速度',
          code: 'speed1',
          unit: "km/h",
          value: '—'
        },
        {
          name: '1轮放线里程',
          code: 'length1',
          unit: "m",
          value: '—'
        },
        {
          name: '放线总里程1',
          code: 'total_length1',
          unit: "m",
          value: '—'
        },
        {
          name: '控制手柄位置',
          code: 'joyst',
          unit: "%",
          value: '—'
        },
        {
          name: '油门踏板位置',
          code: 'pedal',
          unit: "%",
          value: '—'
        },
        {
          name: '制动状态',
          code: 'Brake1',
          value: '—'
        },
        {
          name: '工况状态',
          code: 'Work_select1',
          value: '—'
        },
        {
          name: '控制模式',
          code: 'Control_mode',
          value: '—'
        },
        {
          name: '风扇开关',
          code: 'Fan_IN',
          value: '—'
        },

        {
          name: '风扇状态',
          code: 'Fan_WORK',
          value: '—'
        },
        {
          name: '计程状态',
          code: 'count_set1',
          value: '—'
        },
      ],
      // 牵引机设备参数
      tractorMachParams: [
        {
          name: '牵引力',
          code: 'force1',
          unit: "kN",
          value: '—'
        },
        {
          name: '预置牵引力',
          code: 'force_set1',
          unit: "kN",
          value: '—'
        },
        {
          name: '牵引速度',
          code: 'speed1',
          unit: "km/h",
          value: '—'
        },
        {
          name: '牵引里程',
          code: 'length1',
          unit: "m",
          value: '—'
        },{
          name: '放线总里程1',
          code: 'total_length1',
          unit: "m",
          value: '—'
        },
        {
          name: '控制手柄位置',
          code: 'joyst',
          unit: "%",
          value: '—'
        },
        {
          name: '油门踏板位置',
          code: 'pedal',
          unit: "%",
          value: '—'
        },
        {
          name: '预置牵引速度',
          code: 'speed_set',
          unit: "km/h",
          value: '—'
        },
        {
          name: '制动状态',
          code: 'Brake1',
          value: '—'
        },
        {
          name: '工作模式',
          code: 'Work_mode',
          value: '—'
        },

        {
          name: '控制模式',
          code: 'Control_mode',
          value: '—'
        },
        {
          name: '工作状态',
          code: 'dirObj',
          value: '—'
        },
        {
          name: '风扇开关',
          code: 'Fan_IN',
          value: '—'
        },
        {
          name: '风扇状态',
          code: 'Fan_WORK',
          value: '—'
        },
        {
          name: '计程状态',
          code: 'count_set1',
          value: '—'
        },





      ],
      // 单轮张力机系统参数
      singleSystemParams: [
        {
          name: '系统电压',
          code: 'ubat_supply',
          unit: "V",
          value: '—'
        },
        {
          name: '液压油温度',
          code: 'oil_tem',
          unit: "℃",
          value: '—'
        },
        {
          name: '柴油油位',
          code: 'fuel_level',
          unit: "%",
          value: '—'
        },
        {
          name: '主泵压力',
          code: 'pump1_pressure',
          unit: "bar",
          value: '—'
        },
        {
          name: '1轮压力',
          code: 'main_pressue1',
          unit: "bar",
          value: '—'
        },
        {
          name: '尾架压力',
          code: 'aux_pressue',
          unit: "bar",
          value: '—'
        },
        {
          name: '补油压力',
          code: 'boost_pressure',
          unit: "bar",
          value: '—'
        },
        {
          name: '牵引电流',
          code: 'pos_cur1',
          unit: "mA",
          value: '—'
        },
        {
          name: '送线电流',
          code: 'neu_cur1',
          unit: "mA",
          value: '—'
        },
        {
          name: '控制电流',
          code: 'main_cur1',
          unit: "mA",
          value: '—'
        },
        {
          name: '尾架电流',
          code: 'aux_cur',
          unit: "mA",
          value: '—'
        },
        {
          name: '风扇电流',
          code: 'fan_cur',
          unit: "mA",
          value: '—'
        },
      ],
      // 双轮张力机系统参数
      doubleSystemParams: [
        {
          name: '系统电压',
          code: 'ubat_supply',
          unit: "V",
          value: '—'
        },
        {
          name: '液压油温度',
          code: 'oil_tem',
          unit: "℃",
          value: '—'
        },

        {
          name: '柴油油位',
          code: 'fuel_level',
          unit: "%",
          value: '—'
        },
        {
          name: '主泵压力1',
          code: 'pump1_pressure',
          unit: "bar",
          value: '—'
        },
        {
          name: '1轮压力',
          code: 'main_pressue1',
          unit: "bar",
          value: '—'
        },

        {
          name: '2轮压力',
          code: 'main_pressue2',
          unit: "bar",
          value: '—'
        },
        {
          name: '尾架压力',
          code: 'aux_pressue',
          unit: "bar",
          value: '—'
        },
        {
          name: '补油压力',
          code: 'boost_pressure',
          unit: "bar",
          value: '—'
        },
        {
          name: '牵引电流1',
          code: 'pos_cur1',
          unit: "mA",
          value: '—'
        },
        {
          name: '送线电流1',
          code: 'neu_cur1',
          unit: "mA",
          value: '—'
        },
        {
          name: '控制电流1',
          code: 'main_cur1',
          unit: "mA",
          value: '—'
        },
        {
          name: '控制电流2',
          code: 'main_cur2',
          unit: "mA",
          value: '—'
        },

        {
          name: '尾架电流',
          code: 'aux_cur',
          unit: "mA",
          value: '—'
        },
        {
          name: '风扇电流',
          code: 'fan_cur',
          unit: "mA",
          value: '—'
        },
      ],
      // 牵引机系统参数
      tractorSystemParams: [
        {
          name: '系统电压',
          code: 'ubat_supply',
          unit: "V",
          value: '—'
        },
        {
          name: '液压油温度',
          code: 'oil_tem',
          unit: "℃",
          value: '—'
        },
        {
          name: '柴油油位',
          code: 'fuel_level',
          unit: "%",
          value: '—'
        },
        {
          name: '主泵压力',
          code: 'pump1_pressure',
          unit: "bar",
          value: '—'
        },
        {
          name: '尾架压力',
          code: 'aux_pressue',
          unit: "bar",
          value: '—'
        },
        {
          name: '补油压力',
          code: 'boost_pressure',
          unit: "bar",
          value: '—'
        },
        {
          name: '牵引电流1',
          code: 'pos_cur1',
          unit: "mA",
          value: '—'
        },
        {
          name: '送线电流1',
          code: 'neu_cur1',
          unit: "mA",
          value: '—'
        },
        {
          name: '尾架电流',
          code: 'aux_cur',
          unit: "mA",
          value: '—'
        },
        {
          name: '风扇电流',
          code: 'fan_cur',
          unit: "mA",
          value: '—'
        },
      ],
      // 柴油机参数
      engineMachParams: [
        {
          name: '工作时间',
          code: 'total_engine_hours',
          unit: "h",
          value: '—'
        },
        {
          name: '燃油总消耗',
          code: 'total_fuel_consumption',
          unit: "l",
          value: '—'
        },
        {
          name: '柴油机转速',
          code: 'engine_speed',
          unit: "rpm",
          value: '—'
        },
        {
          name: '当前扭矩',
          code: 'actual_engine_percent_torque',
          unit: "%",
          value: '—'
        },
        {
          name: '当前负载',
          code: 'percent_load_at_current_speed',
          unit: "%",
          value: '—'
        },
        {
          name: '机油温度',
          code: 'engine_oil_temperature',
          unit: "℃",
          value: '—'
        },
        {
          name: '柴油机水温',
          code: 'engine_coolant_temperature',
          unit: "℃",
          value: '—'
        }, {
          name: '机油压力',
          code: 'engine_oil_pressure',
          unit: "bar",
          value: '—'
        },
      ],
      // 系统故障
      systemFault: [
        {
          name: '主泵压力传感器',
          code: 'sErro.press_highsensor1',
          value: '—'
        },
        {
          name: '主压力传感器1',
          code: 'sErro.press_mainsensor1',
          value: '—'
        },
        {
          name: '主压力传感器2',
          code: 'sErro.press_mainsensor2',
          value: '—'
        },
        {
          name: '补油压力传感器',
          code: 'sErro.boostpresssensor',
          value: '—'
        },
        {
          name: '尾架压力传感器',
          code: 'sErro.auxpresssensor',
          value: '—'
        },
        {
          name: '1轮制动电磁铁',
          code: 'sErro.brake1',
          value: '—'
        },
        {
          name: '2轮制动电磁铁',
          code: 'sErro.brake2',
          value: '—'
        },
        {
          name: '控制手柄',
          code: 'sErro.joyst',
          value: '—'
        },
        {
          name: '主泵牵引电磁铁',
          code: 'sErro.pos_cur1',
          value: '—'
        },
        {
          name: '主泵送线电磁铁',
          code: 'sErro.neu_cur1',
          value: '—'
        },
        {
          name: '主比例电磁铁1',
          code: 'sErro.main_cur1',
          value: '—'
        },
        {
          name: '主比例电磁铁2',
          code: 'sErro.main_cur2',
          value: '—'
        },
        {
          name: '尾架比例电磁铁',
          code: 'sErro.struc_cur1',
          value: '—'
        },
        {
          name: '风扇比例电磁铁',
          code: 'sErro.fan_cur1',
          value: '—'
        },
        {
          name: '牵引选择电磁铁1',
          code: 'sErro.select1',
          value: '—'
        },
        {
          name: '牵引选择电磁铁2',
          code: 'sErro.select2',
          value: '—'
        },
        {
          name: '风扇选择电磁铁',
          code: 'sErro.fan_select',
          value: '—'
        },
        {
          name: '并轮选择电磁铁',
          code: 'sErro.bParallel',
          value: '—'
        },

      ],
      // 牵引机系统故障
      tractorSystemFault: [
        {
          name: '主泵压力传感器',
          code: 'sErro.press_highsensor1',
          value: '—'
        },
        {
          name: '主压力传感器1',
          code: 'sErro.press_mainsensor1',
          value: '—'
        },
        {
          name: '主压力传感器2',
          code: 'sErro.press_mainsensor2',
          value: '—'
        },
        {
          name: '补油压力传感器',
          code: 'sErro.boostpresssensor',
          value: '—'
        },
        {
          name: '尾架压力传感器',
          code: 'sErro.auxpresssensor',
          value: '—'
        },
        {
          name: '1轮制动电磁铁',
          code: 'sErro.brake1',
          value: '—'
        },
        {
          name: '2轮制动电磁铁',
          code: 'sErro.brake2',
          value: '—'
        },
        {
          name: '控制手柄',
          code: 'sErro.joyst',
          value: '—'
        },
        {
          name: '主泵牵引电磁铁',
          code: 'sErro.pos_cur1',
          value: '—'
        },
        {
          name: '主泵送线电磁铁',
          code: 'sErro.neu_cur1',
          value: '—'
        },
        {
          name: '主比例电磁铁1',
          code: 'sErro.main_cur1',
          value: '—'
        },
        {
          name: '主比例电磁铁2',
          code: 'sErro.main_cur2',
          value: '—'
        },
        {
          name: '尾架比例电磁铁',
          code: 'sErro.struc_cur1',
          value: '—'
        },
        {
          name: '风扇比例电磁铁',
          code: 'sErro.fan_cur1',
          value: '—'
        },
        {
          name: '牵引选择电磁铁1',
          code: 'sErro.select1',
          value: '—'
        },
        {
          name: '牵引选择电磁铁2',
          code: 'sErro.select2',
          value: '—'
        },
        {
          name: '风扇选择电磁铁',
          code: 'sErro.fan_select',
          value: '—'
        },
        {
          name: '并轮选择电磁铁',
          code: 'sErro.bParallel',
          value: '—'
        },
        {
          name: '摆线电磁铁1',
          code: 'sErro.bswl',
          value: '—'
        },
        {
          name: '摆线电磁铁2',
          code: 'sErro.bsw2',
          value: '—'
        },
      ],
      // 报警提示
      alarmIndication: [
        {
          name: '补油压力不足',
          code: 'sErro.boostpress',
          value: '—'
        },
        {
          name: '尾绳压力不足',
          code: 'sErro.auxpress',
          value: '—'
        },
        {
          name: '电瓶电压不足',
          code: 'sErro.vp1',
          value: '—'
        },
        {
          name: '液压油温度',
          code: 'sErro.oiltemp',
          value: '—'
        },
        {
          name: '燃油不足',
          code: 'sErro_fuellevel',
          value: '—'
        },
      ],
      // 全部设备参数
      allMachParams: [],
      // 全部系统参数
      allSystemParams: [],
      // 全部系统故障
      allSystemFault: [],
    }
  },
  methods: {
    getNameFn(code) {
      let arr = [...this.doubleMachParams, ...this.singleMachParams, ...this.tractorMachParams, ...this.singleSystemParams, ...this.doubleSystemParams, ...this.tractorSystemParams, ...this.engineMachParams, ...this.systemFault, ...this.alarmIndication, ...this.tractorSystemFault];
      for (let i = 0; i < arr.length; i++) {
        if (code == arr[i].code) {
          return arr[i].name
        }
      }
    },
  },
  mounted() {
    let machArr = [...this.doubleMachParams, ...this.singleMachParams, ...this.tractorMachParams];
    let systemArr = [...this.doubleSystemParams, ...this.singleSystemParams, ...this.tractorSystemParams];
    let systemFaultArr = [...this.systemFault, ...this.tractorSystemFault];
    this.allMachParams = filterRepeat(machArr, 'code');
    this.allSystemParams = filterRepeat(systemArr, 'code');
    this.allSystemFault = filterRepeat(systemFaultArr, 'code');
  },
}
